﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using MobileSales.Model.Util;
using System.ComponentModel.DataAnnotations;
using MobileSales.Model.Localization;

namespace MobileSales.Model.Orders
{
    [DataContract]
    public class Order
    {
        #region Public members
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        [Display(Name = "Client", ResourceType = typeof(ModelStrings))]
        public int ClientId { get; set; }
        [DataMember]
        public IEnumerable<OrderItem> Items { get; set; }
        [DataMember(Name="Date")]
        private string _date { get; set; }
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        [Display(Name = "Date", ResourceType = typeof(ModelStrings))]
        public DateTime Date
        {
            get
            {
                if (_date != null) return DateUtil.Deserialize(_date);
                return DateTime.MinValue;
            }
            set
            {
                _date = DateUtil.Serialize(value);
            }
        }
        [DataMember]
        [Display(Name = "OrderStatus", ResourceType = typeof(ModelStrings))]
        public OrderStatus Status { get; set; }
        #endregion
    }
}
